<?php

use yii\grid\GridView;
use yii\helpers\Html;
use common\records\Toy;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '娃娃机';
$this->params['breadcrumbs'][] = $this->title;
$toys = Toy::find()->select("id, name")->where([])->asArray()->all();
$toy_ids = array();
foreach($toys AS $item)
{
    $toy_ids[$item['id']] = $item['name'];
}
?>
<style>
    .machine-index img{width:80px;height:80px;margin-right:10px;}
</style>
<div class="machine-index">
    <?= $this->render('_search', ['model' => $searchModel]) ?>
    <div class="box box-primary">
        <div class="box-body">
            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'columns' => [
                    'id',
                    'mid',
                    [
                        'attribute' => 'toy_id',
                        'value' => function($model){
                            return \common\helpers\Util::getToyName($model->toy_id);
                        }
                    ],
                    'coin',
                    'left_toy',
                    'address',
                    [
                        'attribute' => 'description',
                        'options' => ['width' => '20%'],
                    ],
                    'timestamp',
                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template' => '{view} {update} {delete} ',
                        'buttons' => [
                            
                        ]
                    ],
                ],
            ]); ?>
        </div>
    </div>

</div>
<?php $this->beginBlock('js') ?>
<script>
    layer.ready(function () {
        layer.photos({
            photos:'.machine-index',
            shift:5
        });
    })
</script>
<?php $this->endBlock() ?>
